package com.mondo.financialwallet.presentation.ui.adapter;

import android.support.annotation.Nullable;
import android.text.TextUtils;
import android.widget.ImageView;

import com.bumptech.glide.Glide;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.mondo.financialwallet.R;
import com.mondo.financialwallet.presentation.model.Token;

import java.util.List;

public class TokenListAdapter extends BaseQuickAdapter<Token, BaseViewHolder> {

    public TokenListAdapter(int layoutResId, @Nullable List<Token> data) {
        super(layoutResId, data);
    }

    public TokenListAdapter(int layoutResId) {
        super(layoutResId);
    }

    @Override
    protected void convert(BaseViewHolder helper, Token item) {
        ImageView logoImage = helper.itemView.findViewById(R.id.token_logo_image);
        helper.setText(R.id.name_text_view, item.getName());
        helper.setText(R.id.usd_text_view, item.getUsd());
        helper.setText(R.id.cny_text_view, item.getCny());
        Glide.with(logoImage.getContext()).load(item.getCover()).into(logoImage);
        if (!TextUtils.isEmpty(item.getChineseName())) {
            helper.setText(R.id.chinese_name_text_view, item.getChineseName());
        }
    }
}
